# Maintainer: Noel Kuntze <noel.kuntze@thermi.consulting>
pkgname=libvmime
pkgver=0.9.2k4
pkgrel=10
pkgdesc="Library for working with RFC 5322, MIME messages and IMAP/POP/SMTP"
# ftbfs
#arch="all"
url="https://www.vmime.org/"
license="GPL-3.0-only"
# cmake config file isn't suitable for explicitely setting the TLS lib when it finds gnutls
makedepends="
	!gnutls-dev
	cmake
	cppunit-dev
	doxygen
	graphviz
	gtk+3.0-dev
	libgsasl-dev
	icu-dev
	openssl-dev
	samurai
	"
checkdepends="icu-data-full"
subpackages="$pkgname-dbg $pkgname-dev"
source="libvmime-$pkgver.tar.gz::https://github.com/Kopano-dev/vmime/archive/v$pkgver.tar.gz
	fix-icu-70-1.patch
	gsasl-2.2.0.patch::https://github.com/kisli/vmime/commit/c750e899b8b3a76379167148468e164b7e52f6e2.patch
	"

builddir="$srcdir/vmime-$pkgver"

# can't build in other directory because cmake config is broken here.
# library will not exist at package time.
build() {
	cmake -B . -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr/ \
		-DVMIME_BUILD_TESTS=ON \
		-DVMIME_TLS_SUPPORT_LIB=openssl
	cmake --build .
}

check() {
	LANG=C.UTF-8 build/bin/run-tests
}

package() {
	DESTDIR="$pkgdir" cmake --install .
	mv "$pkgdir/usr/cmake" "$pkgdir/usr/lib/cmake"
}

sha512sums="
90ebce51151944fe9cf09a8385b4ffe4db199c87e79579f66d70221f45a4bf4b048f3115077cff83536119af40ebe89eddacc301b54b7fb017438f44bd0f273c  libvmime-0.9.2k4.tar.gz
65c0c1ec56a9a56167bb8b18e01feee4ea65fa958f5e2f233aa13d0472a803574d8b2751b2e6011edcd1db119f91c66e2401fd4916eecbb3af04dc2e527c125c  fix-icu-70-1.patch
6a07daff1b3830a913df722ed736465e8bbe022ee18b3ba1b704d58d3db16d8bbaeba5daa2e0705792b69aa2ced96b7d3c21a5e43a87b6585eaa318db069054e  gsasl-2.2.0.patch
"
